﻿using Microsoft.AspNetCore.Mvc;
using RuoVea.Auth.Entity;
using RuoVea.EventBus;
using RuoVea.ExApp;
using RuoVea.Web6.Models;
using SqlSugar;
using System.Diagnostics;

namespace RuoVea.Web6.Controllers
{
    public class HomeController : Controller
    {
        private readonly ISqlSugarClient _sqlSugarClient;
        private readonly ILogger<HomeController> _logger;

        public HomeController(ISqlSugarClient sqlSugarClient, ILogger<HomeController> logger)
        {
            _sqlSugarClient = sqlSugarClient;
            _logger = logger;
        }

        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Privacy()
        {
            var tt = App.RootServices;
               IEventPublisher _eventPublisher = App.RootServices.GetService<IEventPublisher>();

            // 判断用户名和密码是否正确(排除全局多租户过滤器)Filter(null,true)
            var user = _sqlSugarClient.Queryable<SysUser>()
                //.WhereIF(input.TenantId.HasValue && input.TenantId.Value > 0, m => m.TenantId == input.TenantId)
                /*.Where(u => u.Account.Equals(input.Account) && u.Password.Equals(encryptPassword) && u.Deleted == IsDelete.N)*/.First();

            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}